﻿using System.Text;

namespace PressTheKey
{
    internal class Program
    {
        const int NumberOfTests = 10;
    static void Main(string[] args)
        {           
            //随机给出提示
            char [] Direction = { 'w','s','a', 'd' }; 
            Random rand = new Random();                      
            //设置时间和错误次数
            int numberOfError = 0;
            DateTime timeStart = DateTime.Now;
            //要求用户按键十次           
            for (int i=0; i<NumberOfTests; i++)
            { 
                int a= rand.Next(Direction.Length);
                Console.WriteLine("请输入相应按键："+Direction[a]);
                //检测用户输入             
                char key = Console.ReadKey(true).KeyChar;
                Console.WriteLine("你输入的按键为：" + key);
                if (key != Direction[a])
                {
                    Console.WriteLine("wrong");
                    numberOfError++;
                }
                else
                    Console.WriteLine("bingo");                                               
            }
            DateTime timeEnd = DateTime.Now;
            TimeSpan reactionTime =  timeEnd - timeStart;
            Console.WriteLine("错误次数：" + numberOfError);
            Console.WriteLine("用时" + reactionTime);                   
        }
    }
}